package com.springJdbc;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:com/springJdbc/Spring-jdbc.xml")
public class TestIdbc {
	
	@Autowired
	//通过注入实现UserDaoImpl的实例化
	private UserDaoImpl userdao;
	
	@Test
	public void testadd(){
		User user = new User();
		user.setUsername("六");
		user.setPassword("123");
		int i = userdao.addUser(user);
		System.out.println(i);
	}
	
	@Test
	public void testdel(){
		User user = new User();
		user.setId(1);
		int i = userdao.delectU(user);
		System.out.println(i);
	}
	@Test
	public void select(){
		List<User> list = userdao.selectOne(2);
		for (User user : list) {
			System.out.println(user);
		}
		User select = userdao.select(3);
		System.out.println(select);
	}
	
	@Test
	public void selectAll(){
		List<User> list = userdao.selectAll();
		for (User user : list) {
			System.out.println(user);
		}
	}
	
	
	
}
